//打开新窗口
function openWin(url){
	location.href = url;
}
//删除或者更新
function checkUpdateOrDelete(url,date){
	var oRadio = document.getElementsByName("ids");
	var flag = true;
	for(var i=0;i<oRadio.length;i++){
		if(oRadio[i].checked){
			if(url.substring(0,6)=="delete"){
				if(!confirm('确实要删除吗?')){
					flag = false;
					break;
				}
			}
			window.location=url+"?id="+oRadio[i].value;
			flag = false;
			
		}
	}
	if(flag){
		alert("请选择"+date);
	}
}
function checkUpdate(url,date){
	var oRadio = document.getElementsByName("ids");
	var flag = true;
	var id;
	var count = 0;
	for(var i=0;i<oRadio.length;i++){
		if(oRadio[i].checked){
			id = oRadio[i].value;
			count++;
			flag = false;
		}
	}
	if(flag){
		alert("请选择"+date);
	}else{
		if(count==1){
			window.location=url+"?id="+id;
			flag = false;
		}else{
			alert("修改"+date+"时，最多选择一项!");
		}
	}
	
}

function checkDelete(url,date){
	var oRadio = document.getElementsByName("ids");
	var flag = true;
	for(var i=0;i<oRadio.length;i++){
		if(oRadio[i].checked){
			id = oRadio[i].value;
			flag = false;
			break;
		}
	}
	if(flag){
		alert("请选择"+date);
		return false;
	}
	if(confirm("确定要删除"+date+"吗?")){
		document.getElementsByTagName("form")[0].action = url;
		return true;
	}
	
}
//全选
function selAll(){
	var array=document.getElementsByName("ids");
	for(var i=0;i<array.length;i++){
			array[i].checked=true;
	}
}
//反选
function reverseSel(){
	var array=document.getElementsByName("ids");
	for(var i=0;i<array.length;i++){
		if(document.getElementsByName("ids")[i].checked==true){
			document.getElementsByName("ids")[i].checked=false;
		}
		else{
			document.getElementsByName("ids")[i].checked=true;
		}
	}
}
//取消选择
function cancelSel(){
	var array=document.getElementsByName("ids");
	for(var i=0;i<array.length;i++){
		if(document.getElementsByName("ids")[i].checked==true){
			document.getElementsByName("ids")[i].checked=false;
		}
	}
}

//隐藏详细信息窗口
function hiddenDetail(oDiv){
	document.getElementById(oDiv).style.visibility="hidden";
}

//显示详细信息窗口
function showDetail(oDiv){
	document.getElementById(oDiv).style.visibility="";
}

//播放列表中用到的js
function returnCheck(){
    var array=document.getElementsByName("ids");
	//因为子窗口不能返回给父窗口对象或者数组（引用类型数据），只能返回基本数据类型数据，所以在此拼装成字符串
	var sb = new StringBuffer(); 
	for(var i=0;i<array.length;i++){
		if(array[i].checked){
			sb.append(array[i].value+","+array[i].title+"|");
		}
	};

	window.opener.bHasSelected = true;
	window.opener.backString = sb.toString();
	window.close();
}

/*
 * 打开新窗口
 */
var hasClose = false;
function openDialog(url,width,height){
	window.open(url,'newwin',"height="+height+", width="+width+", toolbar= no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no,top=150,left=250");
	handle = setInterval(handlerLister,500);
}

function handlerLister(){
	if(hasClose){
		//清理工作		
		bHasSelected = false;
		clearInterval(handle);
		window.location.reload(true);
	}
}
